<template>
  <div>
    <h1>这是其他！</h1>
    <el-button @click="to">前往</el-button>
    <el-button @click="getArticleList">获取</el-button>
  </div>
</template>
<script setup lang="ts">
import { getArticleApi } from "@/api/test/test";
import { HotArticleQuery, HotArticleVo } from "@/api/test/types";
import { Page } from "@/api/page";
// import { router } from "@/router";
import { useRouter } from "vue-router"; // 引入useRouter函数
import { reactive, ref } from "vue";
const router = useRouter(); // 使用useRouter函数获取router实例
const query = reactive<HotArticleQuery>({
  pageIndex: 1,
  pageSize: 10,
  searchKey: "",
});

const articleData = ref<Page<HotArticleVo>>();

function getArticleList() {
  getArticleApi(query).then(res => {
    articleData.value = res.data;
    console.log(articleData.value.records);
    console.log(articleData.value.total);
  });
}

function to() {
  router.push("/");
}
</script>
